﻿using System.Collections.Generic;
using System.Runtime.Serialization;

namespace MusicWorks.Service.DataContracts
{
    [KnownType(typeof(string))]
    [KnownType(typeof(string[]))]
    public class SearchJSONSuggestions : List<object>
    {
        private string Query;
        private string[] Completions;
        private string[] Descriptions;
        private string[] QueryURLs;
        public SearchJSONSuggestions() {  }
        public SearchJSONSuggestions(SearchSuggestions source)
        {
            
            Query = source.Query;
            Completions = new string[source.Section.Count];
            Descriptions = new string[source.Section.Count];
            QueryURLs = new string[source.Section.Count];
            int current = 0;
            foreach (var result in source.Section)
            {
                Completions[current] = result.Text;
                QueryURLs[current] = result.Url;
                Descriptions[current] = result.Description;
                ++current;
            }

            this.Add(Query);
            this.Add(Completions);
            this.Add(Descriptions);
            this.Add(QueryURLs);
        }
    }
}